if(!jsx3.lang.Class.forName("ux.cdb.admin.loan.loanWizard.CoDebitSelect")) {
    jsx3.lang.Class.defineClass("ux.cdb.admin.loan.loanWizard.CoDebitSelect",
            ux.megatron.gui.WizardPanel,
            null,
            function (block) {
                /**
                 * instance initializer
                 * @param strName {String} unique name distinguishing this object from all other JSX GUI objects in the JSX application
                 * @param vntLeft {int|String} either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
                 * @param vntTop {int|String} either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
                 * @param vntWidth {int|String} either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
                 * @param vntHeight {int|String} either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
                 * @param strHTML {String} Text/HTML markup to place in the jsx3.gui.Block instance
                 */
                block.prototype.init = function(strName, vntLeft, vntTop, vntWidth, vntHeight, strHTML) {
                    //call constructor for super class (the super expects the name of the object and the function that it is an instance of)
                    this.jsxsuper(strName, vntLeft, vntTop, vntWidth, vntHeight, strHTML);
                };

                block.prototype.initialize = function(msg) {
                    jsx3.log('step2 pane initialize begin-------------------');
                    try{
                    this.wizard = this.getAncestorOfType("ux.megatron.gui.SteppedWizard");
                    this.dialog = this.getAncestorOfType("ux.cdb.admin.loan.loanWizard.LoanBuilder");

                    //alert(this.dialog.Operation+"||"+this.dailog.comeFrom);
                    if(this.dialog.Operation && this.dialog.Operation == "Edit"){
                        this.wizard.removeStep(0,true);
                        this.dialog.get("buttonPrev").setDisplay(jsx3.gui.Block.DISPLAYNONE,true);
                    }else if(this.dialog.comeFrom && this.dialog.comeFrom == "customer"){
                        this.wizard.removeStep(0,true);
                        this.dialog.get("buttonPrev").setDisplay(jsx3.gui.Block.DISPLAYNONE,true);
                    }
                    }catch(e){
                        jsx3.log('step2 pane initialize: ' + e.message);
                    }
                    jsx3.log('step2 pane initialize end-----------------------');
                }

                block.prototype.onNext = function(objWIZARD, objBUTTON, objEVENT, strCURRENTPANEL) {
                    //return null;		
                    try{
                        var lbl = this.wizard.getMessageLabel();
						var cert_cmm = this.get('blkField_certType');
						if(cert_cmm.extractData()==1||cert_cmm.extractData()==2){ 
			               this.get('blkField_certId').setValidator("Required,IDCard");
			           }else{
			               this.get('blkField_certId').setValidator("Required");
					   }
                        var result =  this.get("block_loan_step2_gd").doValidate();
                        if(result != null){
                            //var tip = ux.megatron.Main.getServer().getDynamicProperty("@cdb@LoanManage@Wizard@WizardSetp2_validateFail");
                            var tip = result[0].label ? result[0].label + ":" + result[0].message : result[0].message;
                            lbl.setColor('red');
                            lbl.setText(tip,true);
                            return 'NONE';
                        }
                        
                        var certType = this.get("blkField_certType").getChild(1).getValue();	
                        if(certType == "01" || certType == "02"){				
                            var certId = this.get("blkField_certId").getChild(1).getValue();
                            if(!certId || !(certId.trim().length == 15 || certId.trim().length == 18)){
                                //var tip = ux.megatron.Main.getServer().getDynamicProperty("@cdb@LoanManage@Wizard@WizardSetp2_certId2");
                            var tip = result[0].label ? result[0].label + ":" + result[0].message : result[0].message;
                                lbl.setColor('red');
                                lbl.setText(tip,true);
                                return 'NONE';
                            }
                        }
                    } catch(ex) {
                        console.log(ex);
                    }
                    lbl.setText('',true);
                    var coDebitName = this.get("blkField_partyName").getChild(1).getValue();
                    this.dialog.coDebitName = coDebitName;
                    var coCertType = this.get("blkField_certType").getChild(1).getText();
                    this.dialog.coCertType = coCertType;
                    var coCertId = this.get("blkField_certId").getChild(1).getValue();
                    this.dialog.coCertId = coCertId;
                    var relatedGuaranteeType = this.get("blkRelationOfStudent").getChild(1).getValue();
                    this.dialog.relatedGuaranteeType = relatedGuaranteeType;
                    jsx3.log('step2 relatedGuaranteeType: ' + relatedGuaranteeType);
                    return null; // return "NONE" to not next panels
                }

                block.prototype.onPrev = function(objWIZARD, objBUTTON, objEVENT, strCURRENTPANEL) {
                    this.wizard.isPrev = true;
					if(this.wizard.__studentId)
						this.dialog._unlockStudent(this.wizard.__studentId);
                    return null; // return "NONE" to not advance panels
                }

                block.prototype.onFinish = function(objWIZARD, objBUTTON, objEVENT, strCURRENTPANEL) {
            var lbl = this.wizard.getMessageLabel();
            var tip = ux.megatron.Main.getServer().getDynamicProperty("@cdb@LoanManage@Wizard@WizardSetp2_validateFail");
                    var tipStep3 = ux.megatron.Main.getServer().getDynamicProperty("@cdb@LoanManage@Wizard@WizardSetp2_step3validateFail");
                    var result =  this.get("block_loan_step2_gd").doValidate();
                    if(result != null){						
                        lbl.setColor('red');
            lbl.setText(tip,true);
                        return 'NONE';
                    }
                    lbl.setText('',true);
                    
                    var block_loan_step3_gd = this.wizard.get("block_loan_step3_gd");
                if(block_loan_step3_gd){
                    var result2 =  block_loan_step3_gd.doValidate();
                        if(result2 != null){
                            //var tip = ux.megatron.Main.getServer().getDynamicProperty("@cdb@LoanManage@Wizard@WizardSetp2_validateFail");
                            lbl.setColor('red');
                lbl.setText(tipStep3,true);
                            return 'NONE';
                        }
                        lbl.setText('',true);
                }else if(this.wizard.Operation == "Insert"){
                    lbl.setColor('red');
            lbl.setText(tipStep3,true);
                        return 'NONE';
                }
          this.dialog.get("wizPane_3").onSaveData();
          
          //this.getAncestorOfType("ux.cdb.admin.loan.loanWizard.LoanBuilder").onClose();   //to be delete
          return null; // return "NONE" to not advance panels
        }

                block.prototype.onRevert = function(objWIZARD, objBUTTON, objEVENT, strCURRENTPANEL) {
                    return null; // return "NONE" to not last status
                }

                block.prototype.onCancel = function(objWIZARD, objBUTTON, objEVENT, strCURRENTPANEL) {
					if(this.wizard.__studentId)
						this.dialog._unlockStudent(this.wizard.__studentId);
					this.getAncestorOfType("ux.cdb.admin.loan.loanWizard.LoanBuilder").onClose();
                    return null; // return "NONE" to not advance panels
                }

                block.prototype.onCustomNav = function(objWIZARD, objBUTTON, objEVENT, strCURRENTPANEL) {
                    return null; // return "NONE" to not advance panels
                }

                block.prototype.onBeforeShow = function(objWIZARD, objBUTTON, objEVENT, strLASTPANEL) {
                    try{
                    if(!this.getChild(0)) {
                        var me = this;
                        ux.megatron.Main.loadUIResourceAsync(me, "ux.cdb.admin","ux/cdb/admin/loan/loanWizard/step2/ui/CoDebitSelectContent.xml", me, me.initialize);
                    }else{
                        this.dialog = this.getAncestorOfType("ux.cdb.admin.loan.loanWizard.LoanBuilder");
                        jsx3.log('step2 onBeforeShow this.dialog: ' + this.dialog);
                        if(this.dialog.Operation && this.dialog.Operation == "Edit"){	
                            var me = this;
        			setTimeout(function() {me.hideButtonPrev();}, 2);						        		
            }else if(this.dialog.comeFrom && this.dialog.comeFrom == "customer"){
                setTimeout(function() {me.hideButtonPrev();}, 2);
            }
                    }
                    }catch(e){
                        jsx3.log('step2 onBeforeShow Error : ' + e.message);
                    }
                    return null; // return "NONE" to not advance panels
                }
                block.prototype.hideButtonPrev = function(){
                    this.dialog.get("buttonPrev").setDisplay(jsx3.gui.Block.DISPLAYNONE,true);   
                }
                block.prototype.onAfterHide = function(objWIZARD, objBUTTON, objEVENT, strNEXTPANEL) {
                    return null; // return "NONE" to not advance panels
                }
            }
    );
}
